1. Field of the Invention
The present invention relates to a hardware structure for adaptively prediction coding an image signal using spatial correlation and a method therefor.
2. Description of the Related Art
In general, an image signal has higher redundancy (reducible information). In order to compress the image signal, Moving Picture Experts Group (MPEG) uses spatial correlation, that is, prediction in a frame, and temporal correlation, that is, prediction between frames.
Among the compression methods, a compression method using spatial correlation in MPEG-4 will now be explained referring to FIGS. 1 and 2
FIG. 1 is a block diagram of a data flow for MPEG-4 coding.
A Forward Discrete Cosine Transform (FDCT) process is performed on an input image signal in an FDCT unit 101. A quantizing unit 102 receives Alternative Current (AC) coefficients and Direct Current (DC) coefficients from the FDCT unit 101, and quantizes the AC and DC coefficients using a quantization table. As the DCT coefficient of a high frequency term of an image signal becomes ‘0’ through quantization, information of the high frequency term is deleted such that data is compressed.
An AC/DC predicting unit 103 receives quantized coefficients, and performs a Differential Pulse Code Modulation (DPCM) process on the AC and the DC coefficients. The result of DPCM process is scanned in a scanning unit 104, and stored in a quantized coefficient buffer 105.
A variable-length coding unit 106 performs variable-length code on the scanned data, and generates a bit stream. At this time, the bit stream is formed with a plurality of packets containing data on a predetermined number of macro blocks.
Meanwhile, in order to reconstruct a scene for motion prediction with respect to temporal correlation, the quantized signal is processed through an inverse quantizing unit 111 and an inverse discrete cosine transform unit 112, and then stored in a frame memory (not shown) in a restorer 113.
FIG. 2 is a block diagram of a data flow for MPEG-4 decoding.
In decoding, a bit stream which is input in units of packets is variable-length decoded in a variable-length decoding unit 201, and stored in a quantized coefficient buffer 202. The stored values are read through inverse scanning by an inverse scanning unit 203, and decoded in an AC/DC predicting unit 204. The decoded result which is the same value as the output of the quantizing unit 102 of FIG. 1, is processed through the inverse quantizing unit 205 and inverse discrete cosine transform unit 206, and restored to a scene in a restoring unit 207.
In order to compress an image signal, MPEG also uses a prediction coding method in addition to the discrete cosine transform and quantization. The prediction coding is a method for reducing the amount of data by using differential coding which codes differences of the AC and DC coefficients output from the quantizing unit 102 and the AC and DC coefficients of a left-hand block, or an upper block.
In MPEG-2, only DC value of the previous macro block is referred to and only DC components are coded using DPCM. In MPEG-4, however, both AC components and DC components are adaptively predictive coded. Referring to FIG. 3, a method for predictive coding AC/DC components in the AC/DC predicting unit 103 of FIG. 1 will now be explained.
Referring to FIG. 3, block X 304 of 8×8 block indicates a current block at the present timing. Block A 303 indicates the preceding block located adjacently in the left-hand side of block X 304, block B 301 in the upper left-hand side of block X 304, and block C 302 in the upper side of block X 304. Grids of each block represent DC components.
In a process for predicting a DC component, a predicted value of a DC component is adaptively selected with respect to the gradient of DC components between blocks adjacent to a current block, in horizontal and vertical directions.
That is, A predicted value of the DC component of block X 304 is determined using the difference between the inverse quantized DC component of block A 303 and the inverse quantized DC component of block B 304, and the difference between the inverse quantized DC component of block C 302 and the inverse quantized DC component of block B 304 That is, the predicted value is determined by the following procedure:       if    ⁢                  ⁢          (              |                                            FA              ⁡                              [                0                ]                                      ⁡                          [              0              ]                                -                                                    FB                ⁡                                  [                  0                  ]                                            ⁡                              [                0                ]                                      |                          <                              |                                                                            FB                      ⁡                                              [                        0                        ]                                                              ⁡                                          [                      0                      ]                                                        -                                                            FC                      ⁡                                              [                        0                        ]                                                              ⁡                                          [                      0                      ]                                                                      |                                                        )                          ⁢                            FB          ⁡                      [            0            ]                          ⁡                  [          0          ]                    =                        FC          ⁡                      [            0            ]                          ⁡                  [          0          ]                      ⁢                      else    ⁢                                    ⁢                            FP          ⁡                      [            0            ]                          ⁡                  [          0          ]                    =                        FA          ⁡                      [            0            ]                          ⁡                  [          0          ]                    where, FA[0][0], FB[0][0], and FC[0][0] are inverse quantized DC components of block A, block B, and block C, respectively, and FP[0][0] is a predicted value of the DC component of block X.
If an adjacent block is not included in the same packet, a predicted value of the DC component of block X is not determined in the above method, but determined using a predetermined reference value. Generally, 1024 is used for the reference value. Thus, even when error occurs in data contained in a packet, propagation of the error to the other packets is prevented.
Using thus obtained predicted value, prediction error PQFX[0][0] is obtained as the following equation:PQFX[0][0]=QFX[0][0]−Fb[0][0]//dc_scalerwhere, QFX[0][0] is the quantized DC component of block X, and dc_scaler is the quantization factor of block X. PQFX[0][0] is variable-length coded by the Huffman coding method. When the image is restored, Fp[0][0]//dc_scaler is added to PQFX[0][0] and the quantized DC coefficient of block X is reproduced. Prediction of a DC coefficient in an intra-block is performed for an entire block (brightness and color-difference components) included in a macro block.
Prediction of an AC component is performed referring to a block which is determined by the DC component prediction. That is, when the DC component is predicted using block A 303, AC coefficients of the first column 311 of block A are taken as predicted values, and are DCPM processed with the AC coefficients of the first column 312 of block X. When the DC component is predicted using block C 302, AC coefficients of the first column 313 of block C are taken as predicted values, and are DCPM processed with the AC coefficients of the first line 314 of block X.
An example of an equation when prediction is performed based on block A is as follows:PQFX[0][i]=QFX[0][i]−(QFA[0][i]*QPA)//QPX
Thus, in order to perform AC/DC prediction, first, it should be determined whether or not an adjacent packet is included in a packet in which a current block is included. In the prior art, all packet numbers (9 bits) located in a slice over a macro block in which prediction is currently performed are stored and in order to determine a packet change, the packet number of the current macro block is compared with the packet number of a macro block desired to be compared. Accordingly, a large space should be allocated to determine a packet change.
Also, when it is determined that an adjacent packet is included in the same packet in which a block for which prediction is currently performed, prediction is performed using DCT components of a left-hand block and a upper block of the current block, thereby storage space for storing DCT components of the left-hand block and the upper block of the current block is needed. However, if the DCT components of adjacent blocks are stored in one line memory space, the DCT component of a upper left-hand block of the current block is not available when prediction of the DCT component of the current block is performed, since the DCT component is stored in a way that the DCT component of the left-hand block is stored in an area in which the DCT component of the upper left-hand block is stored, overlapping the stored DCT component, after prediction of the DCT component of left-hand block is performed Therefore, all DCT components of the blocks of two lines should be stored, which causes increase in circuit area and power consumption such that the method is not appropriate to application fields such as a portable terminal.